<?php
/**
 * Created by PhpStorm.
 * User: Yui
 * Date: 2017/5/12 0012
 * Time: 19:25
 */

namespace backend\controllers;

use common\services\KeywordSve;
use Yii;
use common\controllers\BackendCommonCtrl;

class KeywordController extends BackendCommonCtrl
{
    public function actionEdit()
    {
        $request = Yii::$app->request;
        $KeywordSve = new KeywordSve();
        if ($request->isPost) {
            $post = $request->post();
            $post['keyword_id'] = 1;
            $rs = $KeywordSve->update($post);
            return $this->asJson($rs);
        } else {
            $rs = $KeywordSve->getInfo(['keyword_id' => 1]);
            if ($rs['code'] !== 0) {
                #TODO 404
            }
            return $this->render('edit', ['Keyword' => $rs['data']['Obj']]);
        }
    }
}